import './CommonModel.scss'
import dayjs from 'dayjs'
import { v4 } from 'uuid'
import { useEffect, useState, useRef } from 'react';
import { useRequest } from 'alova/client';
import { useEventEmitter, useMount, useReactive } from 'ahooks';
import {
    Alert, Form, Input, Button, App, Popconfirm, Checkbox, Result,
    Image, Tabs, Timeline, Space, Select, Spin, Badge, Tag, Descriptions
} from 'antd';
import { VideoCameraOutlined, CaretRightOutlined } from '@ant-design/icons';

import { CommonUrl } from '../../Config'
import { Http } from '../../Utils/Api';
import { PutIndexedDB } from '../../Utils/IndexedDB'
import { UserAvatar, UserBackboard } from '../../Config/theme'
import { modelStore, drawerStore } from '../../Config/zustand'

import { FilePreviewSwiper } from '../../Page/Other/Swiper'
import { TemplateCommon } from '../../Temp/Common'
import { FormTempMapping } from '../../Utils/FormTemp'
import { strOfurlParamsFunc, getFileTypeFromUrl } from '../../Utils'

import { VideoTempA02 } from '../../Utils/VideoTemp'
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { ScrollView } from 'devextreme-react/scroll-view'

const { WinBox } = window

const imageUrl = sessionStorage.getItem("IMAGE")
const apiUrl = sessionStorage.getItem("API")

const CommonModel = ({ data, Off }) => {
    const { updateModel } = modelStore()
    const { updateDrawer } = drawerStore()
    const { notification, message } = App.useApp()
    const { uuid, type, row, DevEvent, DateEvent, modelId, tempId, init } = data
    const { send } = useRequest(data => Http(data), { immediate: false })

    const CommonEvent = useEventEmitter()

    const handleData = (e) => {
        const parsedData = JSON.parse(e.data)
        const content = parsedData.content
        return content
    };


    // TODO 通用确认窗口
    if (type === 'commonConfirm') {
        return (
            <div>确认</div>
        )
    }

    // TODO 重置初始密码
    if (type === 'ResetPassword') {
        const [form] = Form.useForm()
        const { userUuid, tableName, password } = data.user
        const onFinish = e => {
            const params = { uuid: userUuid, TableName: tableName, OldPassword: password, NewPassword: e.NewPassword }
            send({ method: 'post', url: 'users/changePassword', params }).then(res => {
                notification.success({ message: '修改成功!', description: '请使用新密码重新登录!' })
                location.reload()
            })
        }
        return (
            <div className='ResetPassword'>
                <Form
                    form={form}
                    autoComplete="off"
                    style={{ maxWidth: 600 }}
                    layout="vertical"
                    onFinish={onFinish}
                >
                    <Alert
                        showIcon
                        type="info"
                        message="为了安全考虑,请重置您的初始化密码!"
                        description='新密码至少包含一个大写,一个小写字母与数字'
                    />
                    <Form.Item label="新密码" name="NewPassword" rules={[{ required: true }]}>
                        <Input.Password placeholder='请输入新密码' />
                    </Form.Item>
                    <Form.Item
                        label="确认密码"
                        name="NewPassword2"
                        dependencies={['NewPassword']}
                        rules={[
                            { required: true },
                            ({ getFieldValue }) => ({
                                validator(_, value) {
                                    if (!value || getFieldValue('NewPassword') === value) { return Promise.resolve() }
                                    return Promise.reject(new Error('两次密码不一致!'));
                                },
                            }),
                        ]}
                    >
                        <Input.Password placeholder='请确认新密码' />
                    </Form.Item>
                    <Form.Item label={null}>
                        <Button type="primary" htmlType="submit">
                            提交新密码
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        )
    }

    // TODO 用户修改密码
    if (type === 'changePassword') {
        const [form] = Form.useForm()
        const { UserInfo } = data
        const { userUuid, tableName } = UserInfo
        const onFinish = e => {
            const params = { uuid: userUuid, TableName: tableName, OldPassword: e.OldPassword, NewPassword: e.NewPassword }
            send({ method: 'post', url: 'users/changePassword', params }).then(res => {
                notification.success({ message: '修改成功!', description: '请使用新密码重新登录!' })
                Off()
            })
        }
        return (
            <div className='ResetPassword'>
                <Form
                    form={form}
                    autoComplete="off"
                    style={{ maxWidth: 600 }}
                    layout="vertical"
                    onFinish={onFinish}
                >
                    <Alert
                        showIcon
                        type="info"
                        message="修改提醒!"
                        description='新密码至少包含一个大写,一个小写字母与数字'
                    />
                    <Form.Item label="原密码" name="OldPassword" rules={[{ required: true }]}>
                        <Input.Password placeholder='请输入新密码' />
                    </Form.Item>
                    <Form.Item label="新密码" name="NewPassword" rules={[{ required: true }]}>
                        <Input.Password placeholder='请输入新密码' />
                    </Form.Item>
                    <Form.Item
                        label="确认密码"
                        name="NewPassword2"
                        dependencies={['NewPassword']}
                        rules={[
                            { required: true },
                            ({ getFieldValue }) => ({
                                validator(_, value) {
                                    if (!value || getFieldValue('NewPassword') === value) { return Promise.resolve() }
                                    return Promise.reject(new Error('两次密码不一致!'));
                                },
                            }),
                        ]}
                    >
                        <Input.Password placeholder='请确认新密码' />
                    </Form.Item>
                    <Form.Item label={null}>
                        <Button type="primary" htmlType="submit">
                            提交新密码
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        )
    }

    // TODO 用户重置密码
    if (type === 'resetPassword') {
        const { UserInfo } = data
        const [Loading, setLoading] = useState(false)
        const { userUuid, tableName, userName } = UserInfo
        const onReset = () => {
            setLoading(true)
            send({ method: 'post', url: 'users/ResetPassword', params: { uuid: userUuid } }).then(() => {
                notification.success({ message: '重置成功!', description: `${tableName}-${fullName} 的密码已重置!` })
                Off()
            })
        }
        return (
            <div className='OptionsModelB0802'>
                <Result
                    status="warning"
                    title={`重置 ${tableName}-${userName} 的密码!`}
                    extra={[
                        <Button key="A01" style={{ width: 160 }} onClick={Off} loading={Loading}>取消</Button>,
                        <Button key="A02" style={{ width: 160 }} type="primary" danger loading={Loading} onClick={onReset}>重置</Button>
                    ]}
                />
            </div>
        )
    }

    // TODO 修改用户信息
    if (type === 'changeUserInfo') {
        const { UserAdd, UserInfo, DataEvent } = data
        const [loading, setLoading] = useState(false)
        const [nickName, setNickName] = useState(UserAdd.nickName)
        const [avatar, setAvatar] = useState(UserAdd.avatar)
        const [backImage, setBackImage] = useState(UserAdd.backImage)

        const onSave = () => {
            // setLoading(true)
            const data = { nickName: nickName || '佚名', avatar, backImage }
            send({ method: 'get', url: 'dictionary/GetJsonInfoByUuid', params: { uuid: 'UserInfo' } }).then(res => {
                res[UserInfo.userUuid] = data
                send({ method: 'post', url: 'dictionary/SaveJsonInfoByUuid', params: { uuid: 'UserInfo', Content: JSON.stringify(res) } })
                    .then(async () => {
                        notification.info({ key: 'success', message: '保存成功!', description: '额外的个人信息以保存!' })
                        await PutIndexedDB('userAdd', data)
                        DataEvent.emit({ type: 'onUpdate' })
                        Off()
                    })
            })
        }


        return (
            <div className='ModifyUserAdd'>
                <div className='avatar'>
                    {Object.keys(UserAvatar).map(key =>
                        <div className={key === avatar ? 'active' : ''} key={key} onClick={() => setAvatar(key)}>
                            <img src={UserAvatar[key]} alt="" />
                        </div>
                    )}
                </div>
                <div className='render'>
                    <div>
                        <img src={UserBackboard[backImage]} alt="" />
                        <div>
                            <svg fill="none" viewBox="0 0 144 62" xmlns="http://www.w3.org/2000/svg">
                                <path fill="#dee2e5" d="m111.34 23.88c-10.62-10.46-18.5-23.88-38.74-23.88h-1.2c-20.24 0-28.12 13.42-38.74 23.88-7.72 9.64-19.44 11.74-32.66 12.12v26h144v-26c-13.22-.38-24.94-2.48-32.66-12.12z" fillRule="evenodd" />
                            </svg>
                            <img src={UserAvatar[avatar]} alt="" />
                            <Input variant="borderless" placeholder='请输入昵称' value={nickName} onChange={e => setNickName(e.target.value)} />
                            <Button type='primary' size='large' onClick={onSave} loading={loading}>保存</Button>
                        </div>
                    </div>
                </div>
                <div className='backImg'>
                    {Object.keys(UserBackboard).map(key =>
                        <div className={key === backImage ? 'active' : ''} key={key} onClick={() => setBackImage(key)}>
                            <img src={UserBackboard[key]} alt="" />
                        </div>
                    )}
                </div>
            </div>
        )
    }

    // TODO 题库选项
    if (type === 'dailyQuizOption') {
        const { uuid } = row.row.data
        const [Options, setOptions] = useState([])

        CommonEvent.useSubscription(val => {
            const { type, data } = val
            if (type === 'onFormBack') {
                const params = { ...data, dailyQuizUuid: uuid }
                if (data.uuid) {
                    send({ method: 'put', url: 'dailyQuizOption', params }).then(res => {
                        DateEvent.emit({ type: 'onRefresh' })
                        CommonEvent.emit({ type: 'closeForm' })
                        getData()
                    })
                } else {
                    send({ method: 'post', url: 'dailyQuizOption', params }).then(res => {
                        DateEvent.emit({ type: 'onRefresh' })
                        CommonEvent.emit({ type: 'closeForm' })
                        getData()
                    })
                }
            }
        })

        const getData = () => {
            send({ method: 'get', url: 'dailyQuizOption', params: { dailyQuizUuid: uuid } }).then(res => {
                res.data.list.sort((a, b) => {
                    if (a.optionKey < b.optionKey) return -1
                    if (a.optionKey > b.optionKey) return 1
                    return 0
                })
                setOptions(res.data.list)
            })
        }

        useMount(() => { getData() })

        const onAdd = () => {
            updateModel({ title: "新增选项", type: 'AddFormData', width: 480, data: { type: 'dailyQuizOption', AddEvnet: CommonEvent } })
        }
        const onModify = (data) => {
            updateModel({ title: "修改选项", type: 'AddFormData', width: 480, data: { type: 'dailyQuizOption', AddEvnet: CommonEvent, Initial: data } })
        }

        const onDel = e => {
            send({ method: 'delete', url: 'dailyQuizOption', params: { uuid: e.uuid } }).then(res => {
                DateEvent.emit({ type: 'onRefresh' })
                CommonEvent.emit({ type: 'closeForm' })
                getData()
            })
        }

        return (
            <div className='dailyQuizOption'>
                <div className='OptioList'>
                    {Options.map((item) =>
                        <div key={item.uuid}>
                            <div>
                                <div>{item.optionKey}.</div>
                                <div>{item.optionContent}</div>
                            </div>
                            <div>
                                <Button type='link' onClick={() => onModify(item)}>修改</Button>
                                <Popconfirm
                                    title="删除提醒"
                                    description="是否删除当前答案选项?"
                                    onConfirm={() => onDel(item)}
                                    okText="删除"
                                    cancelText="取消"
                                >
                                    <Button type='link' danger>删除</Button>
                                </Popconfirm>

                            </div>
                        </div>
                    )}
                </div>
                <div>
                    <Button type='primary' onClick={onAdd}>新增选项</Button>
                </div>
            </div>
        )
    }
    // TODO 题库答案
    if (type === 'dailyQuizAnswer') {
        const { uuid, tableName, explanation } = row.row.data

        const [CheckData, setCheckData] = useState([])
        const [Options, setOptions] = useState([])
        const onChange = (e) => {
            setCheckData(e)
            send({ method: 'post', url: 'dailyQuizAnswer', params: { dailyQuizUuid: uuid, dailyQuizOptionUuid: e.join(',') } }).then(() => {
                DateEvent.emit({ type: 'onRefresh' })
            })
        }

        useMount(() => {
            send({ method: 'get', url: 'dailyQuizOption', params: { dailyQuizUuid: uuid } }).then(res => {
                res.data.list.sort((a, b) => {
                    if (a.optionKey < b.optionKey) return -1
                    if (a.optionKey > b.optionKey) return 1
                    return 0
                })
                setOptions(res.data.list)
            })
            send({ method: 'get', url: 'dailyQuizAnswer', params: { dailyQuizUuid: uuid } }).then(res => {
                setCheckData(res.data.dailyquizoptionuuids.split(','))
            })
        })

        return (
            <div className='dailyQuizAnswer'>
                <div>
                    <div>问 : </div>
                    <div>{tableName}</div>
                </div>
                <div>
                    <div>Ps : </div>
                    <div>{explanation}</div>
                </div>
                <div>
                    <Checkbox.Group value={CheckData} onChange={onChange}>
                        {Options.map(item =>
                            <Checkbox key={item.uuid} value={item.uuid}>{item.optionKey}. {item.optionContent}</Checkbox>
                        )}
                    </Checkbox.Group>
                </div>
            </div>
        )
    }

    // TODO 文章预览
    if (type === 'filePreview') {
        const {
            tableName, organizationName, coverUrlList, releaseDate,
            departmentTypeName, mediaTypeName, publishStatusName,
            articleType, articleTypeName, articleAttachment, newsContent,
        } = row.row.data
        console.log(row.row.data)
        const [visible, setVisible] = useState(false)

        useMount(() => {
            if (articleType === '2bf6d170-ff98-4c77-8dd6-38b8dcad9c78') {
                window.open(newsContent)
                Off()
            }
        })

        return (
            <div className='filePreview'>
                <div className='Title'>
                    {tableName}
                    <span>({organizationName})</span>
                    <Button type='line' onClick={() => setVisible(true)}>封面</Button>
                </div>
                <div className='Type'>
                    <div>{departmentTypeName}/{mediaTypeName}/{articleTypeName}</div>
                    <div>{publishStatusName} {releaseDate}</div>
                </div>
                <div className='Content'>
                    {articleType === 'd59f00a5-b74b-4afb-9399-08fee1b4184e' &&
                        <FilePreviewSwiper data={articleAttachment} />
                    }
                    {articleType === '04a8f3c5-2d4c-48ef-8391-9572cd66e3f4' &&
                        <div className='HTML' dangerouslySetInnerHTML={{ __html: newsContent }} />
                    }
                </div>
                <Image
                    width={200}
                    style={{ display: 'none' }}
                    src='https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
                    preview={{ visible, src: coverUrlList[0].url, onVisibleChange: setVisible }}
                />
            </div>
        )
    }
    // TODO 锁屏动画
    if (type === 'lockAnimation') {
        return (
            <div>锁屏动画</div>
        )
    }

    // TODO 富文本编辑器
    if (type === 'textEditing') {
        const [Value, setValue] = useState('')
        const [loading, setLoading] = useState(false)
        const { uuid } = row.row.data

        useMount(() => {
            send({ method: 'get', url: 'newsRelease/GetNewsReleaseOneInfo', params: { uuid } }).then(res => {
                const [{ newsContent }] = res.data.list
                setValue(newsContent)
            })
        })

        const onSave = () => {
            setLoading(true)
            row.row.data.newsContent = Value
            send({ method: 'put', url: 'newsRelease', params: row.row.data }).then(() => {
                message.success("保存成功")
                setLoading(false)
            })
        }

        return (
            <div className='textEditing'>
                <div className='Left'>
                    <div className='HTML' dangerouslySetInnerHTML={{ __html: Value }} />
                </div>
                <div className='Right'>
                    <Input.TextArea value={Value} onChange={e => setValue(e.target.value)} />
                    <Button type='primary' loading={loading} onClick={onSave}>保存</Button>
                </div>
            </div>
        )
    }

    // TODO 班前活动
    if (type === 'PreClassActivities') {

        const TextMapping = [
            { value: 'department', label: '部位' },
            { value: 'workDate', label: '日期' },
            { value: 'workContent', label: '工作内容' },
            { value: 'siteResponsiblePerson', label: '现场负责人' },
            { value: 'participantCount', label: '参与人数' },
            { value: 'workEnvironmentDescription', label: '作业环境' },
            { value: 'protectiveEquipmentWorn', label: '防护用品' },


        ]

        const VideoMapping = [
            // { value: 'protectiveEquipmentWorn', label: '防护用品佩戴', url: 'protectiveEquipmentWornAttachment' },
            // { value: 'workEnvironmentDescription', label: '作业环境描述', url: 'workEnvironmentDescriptionAttachment' },
            // { value: 'morningEducationVideo', label: '早班教育参与情况视频', url: 'morningEducationVideoAttachment' },
            { value: 'earlyChildhoodEducation', label: '早班教育内容视频', url: 'earlyChildhoodEducationAttachment' },
            { value: 'otherDetails', label: '其他', url: 'otherDetailsAttachment' },

        ]

        const onClickVideo = (url) => {
            new WinBox({
                title: '视频',
                x: "center",
                y: "center",
                width: "80%",
                height: "80%",
                zIndex: 1001,

                background: 'linear-gradient(45deg, #ff00f0, #0050ff)',
                html: `<video src="${url}" width="100%" controls></video>`,

            })
        }


        return (
            <div className='PreClassActivities'>
                {TextMapping.map(({ value, label }) =>
                    <div key={value} className='Label'>
                        <div>{label} : </div>
                        <div>{row.row.data[value]}</div>
                    </div>
                )}
                <div style={{ height: 24 }} />

                {VideoMapping.map(({ value, label, url }) =>
                    <div key={value} className='Annex'>
                        <div>{label}</div>
                        <div>
                            {row.row.data[url].map(({ uuid, url }) => {
                                const [name] = url.split('.').slice(-1)
                                const ImgMapping = ['JPG', 'PNG', 'JPEG']
                                const VideoMapping = ['MP4', 'MOV', 'AVI']
                                if (ImgMapping.includes(name.toUpperCase())) return <Image key={uuid} width={200} src={url} />
                                if (VideoMapping.includes(name.toUpperCase())) {
                                    return (
                                        <div className='Video' key={uuid} onClick={() => onClickVideo(url)}>
                                            <VideoCameraOutlined />
                                        </div>
                                    )
                                }
                            })}
                        </div>
                        <div>
                            <div>备注 : </div>
                            <div>{row.row.data[value]}</div>
                        </div>
                    </div>
                )}
            </div>
        )
    }

    // TODO 自定义模块选择
    if (type === 'customModule') {

        const groupByType = (data) => {
            const grouped = {}
            for (const key in data) {
                const item = data[key]
                const types = item.type
                types.forEach(type => {
                    if (!grouped[type]) grouped[type] = []
                    grouped[type].push(item)
                })
            }
            return Object.entries(grouped).map(([type, items]) => ({ type, items }))
        }

        const result = groupByType(TemplateCommon)

        const items = result.map(({ type, items }) => ({
            key: type,
            label: type,
            children: (
                <div className='Items'>
                    {items.map(({ name, title, temp }) => {
                        const Template = temp
                        return (
                            <div key={name} onClick={() => DateEvent.emit({ type: 'onSelectTemp', data: { modelId, tempId, name } })}>
                                <Template />
                                <div>{title}</div>
                            </div>
                        )
                    })}
                </div>
            )
        }))

        return (
            <div className='customModule'>
                <Tabs items={items} />
            </div>
        )
    }

    // TODO 自定义模块参数
    if (type === 'customModuleParams') {
        const { formItem, initData } = data

        const FORMEVENT = useEventEmitter()
        FORMEVENT.useSubscription(val => {
            const { type, data } = val
            if (type === 'onFormBack') {
                DateEvent.emit({ type: 'onFormBack', data: { uuid, params: data } })
                Off()
            }
        })

        return (
            <div className='customModuleParams'>
                {formItem && <FormTempMapping formItem={formItem} FORMEVENT={FORMEVENT} Initial={initData} NotLoading />}
            </div>
        )
    }
    // TODO 执行接口
    if (type === 'execute') {
        const { modelTips, formMethod, formUrl, formParams, sendData = [], isData, dataArr } = data.params
        const onClikc = () => {
            const params = sendData.reduce((acc, { key, value }) => { acc[key] = value; return acc; }, {})
            if (isData) dataArr.forEach(({ dataKey, dataMap }) => params[dataKey] = row.row.data[dataMap])
            send({ method: formMethod, url: formUrl, params: { ...strOfurlParamsFunc(formParams), ...params } }).then(res => {
                DateEvent.emit({ type: 'onRefresh' })
                Off()
            })
        }

        return (
            <Result
                status="warning"
                title={modelTips}
                extra={[
                    <Button type="default" key="A01" onClick={Off} style={{ width: 120 }}>
                        取消
                    </Button>,
                    <Button type="primary" key="A02" onClick={onClikc} style={{ width: 120 }}>
                        确定
                    </Button>
                ]}
            />
        )
    }

    // TODO 合同对比
    if (type === 'ContractComparison') {
        const { notification } = App.useApp();
        const scrollContainerRef = useRef(null);
        const { uuid, organizationUuid } = row.row.data
        const [{ url }] = row.row.data.contractAttachment
        const init = useReactive({ Result: '' })

        const [List, setList] = useState()
        const [Start, setStart] = useState(false)
        const [Active, setActive] = useState('')

        const { send } = useRequest(data => Http(data), { immediate: false })

        const getData = () => {
            send({ method: 'GET', url: 'contractTemplate', params: { pageIndex: 1, pageSize: 10000 } }).then(res => {
                const data = res.data.list.map(item => {
                    if (item.contractAttachment.length !== 0) {
                        return ({
                            uuid: item.uuid,
                            label: item.tableName,
                            value: item.contractAttachment[0].url
                        })
                    }
                    else return false
                }).filter(item => item !== false)
                setList(data)
            })
        }

        const onResult = () => {
            if (!Active) return false
            init.Result = ''
            setStart(true)
            const acDocx = Active.replace(/.pdf/, '.docx')
            const tgDocx = url.replace(/.pdf/, '.docx')
            var eventSource = new EventSource(`https://coze.tonzoc.com.cn/compare_contract?template_contract_file_url=${acDocx}&target_contract_file_url=${tgDocx}`)
            eventSource.onopen = e => { console.log('开始解析') }
            eventSource.onmessage = e => init.Result = `${init.Result}${handleData(e)}`
            eventSource.onerror = (e) => {
                eventSource.close()
                setStart(false)
            }
            eventSource.addEventListener('completed', (event) => {
                eventSource.close()
                setStart(false)
            })
        }

        useMount(getData)

        const onSave = () => {
            if (init.Result === '' || !Active || Start) {
                notification.info({ message: '操作提醒!', description: '请先AI分析或等待分析完成!', key: 'ContractComparison' })
                return false
            }
            const contractTemplateUuid = List.find(v => v.value === Active).uuid
            const params = {
                contractInformationUuid: uuid,
                contractTemplateUuid,
                organizationUuid,
                reviewStatusContent: init.Result
            }

            send({ method: 'POST', url: 'contractCompare/AddContractCompareZhaoJun', params }).then(res => {
                notification.success({ message: '保存成功!', key: 'ContractComparison' })
            })
        }

        return (
            <div className='ContractComparison'>
                <div className='Left'>
                    <div className='Title'>合同信息</div>
                    <div className='PDF'>
                        <embed className='File' src={url} />
                    </div>
                    <div className='Select'>
                        {List &&
                            <Space.Compact>
                                <Select
                                    placeholder='请选择模板'
                                    options={List}
                                    size='large'
                                    value={Active}
                                    onChange={setActive}
                                    disabled={Start}
                                    showSearch
                                />
                                <Button type='primary' onClick={() => onResult()} size='large' loading={Start}>{Start ? '解析中...' : '解析'}</Button>
                            </Space.Compact>
                        }
                    </div>
                    <div className='PDF'>
                        {Active ?
                            <embed className='File' src={Active} /> :
                            <Result status="warning" title="请选择需对比的模板文件." />
                        }
                    </div>
                </div>

                <div className='Right'>
                    <div className='TitleA'>· 智能解析</div>
                    <div className='TitleB'>对比结果</div>
                    <div className='content'>
                        <ScrollView
                            height='100%'
                            width='100%'
                            direction="vertical"
                            showScrollbar='onHover'
                            bounceEnabled={false}
                            elementAttr={{ class: 'style' }}
                            scrollByContent={true}
                            scrollByThumb={true}
                        >
                            <div>
                                <ReactMarkdown remarkPlugins={[[remarkGfm, { singleTilde: true }]]}  >
                                    {init.Result}
                                </ReactMarkdown>
                            </div>
                        </ScrollView>
                    </div>
                    <img src={CommonUrl + '/AIRobot.png'} alt="" />
                    <div className='Options'>
                        <Button onClick={onResult}>重新对比</Button>
                        <Button type='primary' onClick={onSave}>保存对比</Button>
                    </div>
                </div>
            </div>
        )

    }

    // TODO 合同审核
    if (type === 'contractReview') {
        const { notification } = App.useApp();
        const scrollContainerRef = useRef(null);
        const { uuid, organizationUuid } = row.row.data
        const [{ url }] = row.row.data.contractAttachment
        const init = useReactive({ Result: '' })

        const [Active, setActive] = useState([])
        const [List, setList] = useState()
        const [Start, setStart] = useState(false)

        const { send } = useRequest(data => Http(data), { immediate: false })

        const getData = () => {
            send({ method: 'GET', url: 'contractReview/GetContractReviewRulesListByRules', params: { organizationUuid } }).then(res => {
                const data = res.data.list.map(item => ({ uuid: item.uuid, value: item.tableName, label: item.tableName }))
                setList(data)
            })
        }

        useMount(getData)

        const onResult = () => {
            if (Active.length === 0) return false
            init.Result = ''
            setStart(true)
            const tgDocx = url.replace(/.pdf/, '.docx')
            var eventSource = new EventSource(`https://coze.tonzoc.com.cn/universal?file_url=${tgDocx}&prompt_str=${Active.join(',')}`)
            eventSource.onopen = e => { console.log('开始解析') }
            eventSource.onmessage = e => init.Result = `${init.Result}${handleData(e)}`
            eventSource.onerror = (e) => {
                eventSource.close()
                setStart(false)
            }
            eventSource.addEventListener('completed', (event) => {
                eventSource.close()
                setStart(false)
            })
        }

        const onSave = () => {
            if (init.Result === '' || !Active || Start) {
                notification.info({ message: '操作提醒!', description: '请先AI分析或等待分析完成!', key: 'ContractComparison' })
                return false
            }
            const uuids = Active.map(item => (List.find(v => v.value === item).uuid))
            const params = { contractInformationUuid: uuid, riskRulesUuid: uuids, organizationUuid, reviewStatusContent: init.Result }

            send({ method: 'POST', url: 'contractReview/AddContractReviewZhaoJun', params }).then(res => {
                notification.success({ message: '保存成功!', key: 'ContractComparison' })
            })
        }

        return (
            <div className='contractReview' ref={scrollContainerRef} >
                <div className='Left'>
                    <div className='Select'>
                        {List &&
                            <Space.Compact>
                                <Select
                                    mode='multiple'
                                    placeholder='请选择模板'
                                    options={List}
                                    size='large'
                                    value={Active}
                                    onChange={setActive}
                                    disabled={Start}
                                    showSearch
                                />
                                <Button type='primary' onClick={onResult} size='large' loading={Start}>{Start ? '解析中...' : '解析'}</Button>
                            </Space.Compact>
                        }
                    </div>
                    <div className='Title'>合同信息</div>
                    <div className='PDF'>
                        <embed className='File' src={url} />
                    </div>
                </div>
                <div className='Right'>
                    <div className='TitleA'>· 智能解析</div>
                    <div className='TitleB'>审核结果</div>
                    <div className='content'>
                        <ScrollView
                            height='100%'
                            width='100%'
                            direction="vertical"
                            showScrollbar='onHover'
                            bounceEnabled={false}
                            elementAttr={{ class: 'style' }}
                            scrollByContent={true}
                            scrollByThumb={true}
                        >
                            <div>
                                <ReactMarkdown remarkPlugins={[[remarkGfm, { singleTilde: true }]]}  >
                                    {init.Result}
                                </ReactMarkdown>
                            </div>
                        </ScrollView>
                    </div>
                    <img src={CommonUrl + '/AIRobot.png'} alt="" />
                    <div className='Options'>
                        <Button onClick={onResult}>重新审核</Button>
                        <Button type='primary' onClick={onSave}>保存审核</Button>
                    </div>
                </div>
            </div>
        )
    }

    // TODO 合同提取
    if (type === 'ContractExtraction') {
        const { notification } = App.useApp();
        const scrollContainerRef = useRef(null);
        const { uuid, organizationUuid } = row.row.data
        const [{ url }] = row.row.data.contractAttachment
        const init = useReactive({ Result: '' })

        const [Active, setActive] = useState([])
        const [List, setList] = useState()
        const [Start, setStart] = useState(false)

        const { send } = useRequest(data => Http(data), { immediate: false })

        const getData = () => {
            send({ method: 'GET', url: 'contractReview/GetContractReviewRulesListByRules', params: { organizationUuid } }).then(res => {
                const data = res.data.list.map(item => ({ uuid: item.uuid, value: item.tableName, label: item.tableName }))
                setList(data)
            })
        }

        useMount(getData)

        const onResult = () => {
            if (Active.length === 0) return false
            init.Result = ''
            setStart(true)
            const tgDocx = url.replace(/.pdf/, '.docx')
            var eventSource = new EventSource(`https://coze.tonzoc.com.cn/universal?file_url=${tgDocx}&prompt_str=${Active.join(',')}`)
            eventSource.onopen = e => { console.log('开始解析') }
            eventSource.onmessage = e => init.Result = `${init.Result}${handleData(e)}`
            eventSource.onerror = (e) => {
                eventSource.close()
                setStart(false)
            }
            eventSource.addEventListener('completed', (event) => {
                eventSource.close()
                setStart(false)
            })
        }

        const onSave = () => {
            if (init.Result === '' || !Active || Start) {
                notification.info({ message: '操作提醒!', description: '请先AI分析或等待分析完成!', key: 'ContractComparison' })
                return false
            }
            const uuids = Active.map(item => (List.find(v => v.value === item).uuid))
            const params = { contractInformationUuid: uuid, riskRulesUuid: uuids, organizationUuid, reviewStatusContent: init.Result }

            send({ method: 'POST', url: 'contractExtract/AddContractExtractZhaoJun', params }).then(res => {
                notification.success({ message: '保存成功!', key: 'ContractComparison' })
            })
        }

        return (
            <div className='contractReview' ref={scrollContainerRef} >
                <div className='Left'>
                    <div className='Select'>
                        {List &&
                            <Space.Compact>
                                <Select
                                    mode='multiple'
                                    placeholder='请选择模板'
                                    options={List}
                                    size='large'
                                    value={Active}
                                    onChange={setActive}
                                    disabled={Start}
                                    showSearch
                                />
                                <Button type='primary' onClick={onResult} size='large' loading={Start}>{Start ? '解析中...' : '解析'}</Button>
                            </Space.Compact>
                        }
                    </div>
                    <div className='Title'>合同信息</div>
                    <div className='PDF'>
                        <embed className='File' src={url} />
                    </div>
                </div>
                <div className='Right'>
                    <div className='TitleA'>· 智能解析</div>
                    <div className='TitleB'>提取结果</div>
                    <div className='content'>
                        <ScrollView
                            height='100%'
                            width='100%'
                            direction="vertical"
                            showScrollbar='onHover'
                            bounceEnabled={false}
                            elementAttr={{ class: 'style' }}
                            scrollByContent={true}
                            scrollByThumb={true}
                        >
                            <div>
                                <ReactMarkdown remarkPlugins={[[remarkGfm, { singleTilde: true }]]}  >
                                    {init.Result}
                                </ReactMarkdown>
                            </div>
                        </ScrollView>
                    </div>
                    <img src={CommonUrl + '/AIRobot.png'} alt="" />
                    <div className='Options'>
                        <Button onClick={onResult}>重新提取</Button>
                        <Button type='primary' onClick={onSave}>保存提取</Button>
                    </div>
                </div>
            </div>
        )
    }

    // TODO 单题解析
    if (type === 'SingleAnalysis') {
        const { data } = row.row
        const { uuid, category, tableName } = data

        const [Result, setResult] = useState('')

        const getData = () => {
            var eventSource = new EventSource(`https://coze.tonzoc.com.cn/parse_questions_by_uuids?question_uuids=${uuid}`)
            eventSource.onopen = e => {
                console.log('链接成功')
            }
            eventSource.onmessage = e => {
                setResult(data => {
                    const str = `${data}${JSON.parse(e.data).content === '\n' || JSON.parse(e.data).content === '\n\n' ? '</br>' : JSON.parse(e.data).content}`
                    return (str)
                })
            }
            eventSource.onerror = (e) => {
                eventSource.close()
            }
            eventSource.addEventListener('completed', (event) => {
                eventSource.close()
            });

        }
        useMount(getData)

        return (
            <div className='SingleAnalysis'>
                <div>
                    <div>题目类型 : </div>
                    <div>{category}</div>
                </div>
                <div>
                    <div>题目内容 : </div>
                    <div>{tableName}</div>
                </div>
                <div className='Result' dangerouslySetInnerHTML={{ __html: Result }}></div>
            </div>
        )
    }

    if (type === 'batchParsing') {
        const [Start, setStart] = useState(false)
        const [Result, setResult] = useState('')
        const getData = () => {
            var eventSource = new EventSource(`https://coze.tonzoc.com.cn/parse_questions_by_uuids?question_uuids=${init.join(',')}`)
            eventSource.onopen = e => {
                console.log('链接成功')
            }
            eventSource.onmessage = e => {
                setResult(data => {
                    const str = `${data}${JSON.parse(e.data).content === '\n' || JSON.parse(e.data).content === '\n\n' ? '</br>' : JSON.parse(e.data).content}`
                    return (str)
                })
            }
            eventSource.onerror = (e) => {
                eventSource.close()
            }
            eventSource.addEventListener('completed', (event) => {
                setStart(true)
                eventSource.close()
            });

        }
        useMount(() => {
            if (init.length !== 0) {
                getData()
            }
        })


        if (init.length === 0) {
            return (
                <div className='batchParsingEmpty'>
                    <Result status="403" title="请选择需解析的问题数据" />
                </div>
            )
        }
        return (
            <div className='batchParsingEmpty'>
                <div className='Result' dangerouslySetInnerHTML={{ __html: Result }}></div>
                <div className='Success'>{Start ? '解析完成' : '正在解析...'}</div>
            </div>
        )
    }

    if (type === 'AllAnalysis') {
        // https://coze.tonzoc.com.cn/parse_question

        const getData = () => {
            var eventSource = new EventSource('https://coze.tonzoc.com.cn/parse_question')
            eventSource.onopen = e => {
                console.log('链接成功')
            }
            eventSource.onmessage = e => {
                console.log(JSON.parse(e.data))
                // setResult(data => {
                //     const str = `${data}${JSON.parse(e.data).content === '\n' || JSON.parse(e.data).content === '\n\n' ? '</br>' : JSON.parse(e.data).content}`
                //     return (str)
                // })
            }
            eventSource.onerror = (e) => {
                eventSource.close()
            }
            eventSource.addEventListener('completed', (event) => {
                setStart(true)
                eventSource.close()
            });

        }


        useMount(getData)

        return (
            <div>全部解析</div>
        )
    }

    if (type === 'SecurityDetails') {
        const { uuid, pitfallAttachment, auditStatusName, organizationName, securityDate, problem,
            hiddenDangerName, securityProblemTypeName, causingTypesName, limitDays
        } = row.row.data
        const items = pitfallAttachment.map(item => (item.url))

        const [Data, setData] = useState([])
        const [Active, setActive] = useState()


        useMount(() => {
            send({ method: 'get', url: 'securityDetail', params: { securityUuid: uuid, menuUuid: 'ad724d96-dba6-43b7-801c-61121e6e6756' } }).then(res => {
                setData(res.data.list)
                setActive(res.data.list[0].uuid)
            })
        })

        const itemsData = [
            { key: '8', label: '流程状态', children: auditStatusName },
            { key: '1', label: '组织机构', children: organizationName },
            { key: '2', label: '下单日期', children: securityDate },
            { key: '3', label: '隐患名称', children: problem },
            { key: '4', label: '隐患部位', children: hiddenDangerName },
            { key: '5', label: '隐患等级', children: securityProblemTypeName },
            { key: '6', label: '事故类型', children: causingTypesName },
            { key: '7', label: '治理时限', children: limitDays },
        ];

        const statusMapping = {
            'e9744b20-9487-457d-9e4b-1256bd47025a': '#13c2c2',
            'e70f70c7-1e1a-4906-885a-b20b620cab30': '#1677ff',
            'ccdcfb2b-20ca-4569-905d-0bcc71cdbc98': '#f5222d',
            '65ae3568-f430-4e23-abd8-6429415ef12f': '#52c41a',
        }

        return (
            <div className='SecurityDetails'>
                <div className='Top'>
                    <Image.PreviewGroup items={items}>
                        <Image width={240} height={240} src={items[0]} />
                    </Image.PreviewGroup>
                    <Descriptions title="整改问题" column={2} items={itemsData} />
                </div>
                <div className='Bottom'>
                    <div className='List'>
                        {Data.map(item => (
                            <div
                                className={Active === item.uuid ? 'active' : ''}
                                key={item.uuid}
                                onClick={() => setActive(item.uuid)}
                            >
                                {item.tableName}
                            </div>
                        ))}
                    </div>
                    <div className='Details'>
                        {(() => {
                            if (!Active || !Data) return false
                            const {
                                tableName,
                                securityDetailDate,
                                description,
                                processDescription,
                                processAttachment,
                                resultDescription,
                                resultAttachment,
                                handlingName,
                                reviewerName,
                                reviewTime
                            } = Data.find(v => v.uuid === Active)

                            const itemsDataContent = [
                                { key: '4', label: '整改状态', children: handlingName },
                                { key: '1', label: '整改日期', children: securityDetailDate },
                                { key: '2', label: '整体描述', children: description },
                                { key: '3', label: '过程描述', children: resultDescription },
                                { key: '5', label: '审核人', children: reviewerName },
                                { key: '6', label: '审核时间', children: reviewTime },
                            ];

                            const image1 = processAttachment.map(item => (item.url))
                            const image2 = resultAttachment.map(item => (item.url))

                            return (
                                <>
                                    <Descriptions title={tableName} column={2} items={itemsDataContent} />
                                    <Image.PreviewGroup items={image1}>
                                        <Image width={380} height={380} src={image1[0]} />
                                    </Image.PreviewGroup>
                                    <Image.PreviewGroup items={image2}>
                                        <Image width={380} height={380} src={image2[0]} />
                                    </Image.PreviewGroup>
                                </>
                            )
                        })()}
                    </div>
                </div>
            </div>
        )
    }

    // TODO 随手拍流程
    if (type === 'SecurityTimeline') {
        const [List, setList] = useState([])
        useMount(() => {
            send({ method: 'get', url: 'security/GetSecurityProcessStepsList', params: { SecurityUuid: row.row.data.uuid } }).then(res => {
                // console.log()
                setList(res.data.list)
            })
        })

        const statusMapping = {
            0: { title: '待完成', color: '#f5222d' },
            1: { title: '已完成', color: '#52c41a' },
        }

        return (
            <div className='SecurityTimeline'>
                <Timeline
                    items={(() => {
                        const data = List.map(item => {
                            return ({
                                color: statusMapping[item.completionStatus].color,
                                children: (
                                    <div className='TimelineData'>
                                        <div>流程名称 : {item.fullName}</div>
                                        <div>操作人员 : {item.updateUserName}</div>
                                        <div>确认时间 : {item.updateTime}</div>
                                        <div>操作状态 : {statusMapping[item.completionStatus].title}</div>
                                    </div>
                                )
                            })
                        })
                        return data
                    })()}
                />
            </div>
        )
    }
    // TODO 操作日志
    if (type === 'SecurityOperationLog') {

        const [List, setList] = useState([])
        useMount(() => {
            send({ method: 'get', url: 'security/GetSecurityOperationLog', params: { securityUuid: row.row.data.uuid } }).then(res => {
                // console.log(res.data.list)
                setList(res.data.list)
            })
        })

        const statusMapping = {
            '隐患下单': { title: '待完成', color: '#1677ff' },
            '修改隐患数据': { title: '已完成', color: '#13c2c2' },
            '删除隐患数据': { title: '待完成', color: '#f5222d' },
            '提交隐患': { title: '已完成', color: '#52c41a' },
            '确认操作': { title: '待完成', color: '#1677ff' },
            '审核操作': { title: '已完成', color: '#1677ff' },
            '复核操作': { title: '已完成', color: '#1677ff' },
            '记录整改详情': { title: '待完成', color: '#1677ff' },
            '修改整改详情': { title: '已完成', color: '#13c2c2' },
            '删除整改详情': { title: '待完成', color: '#f5222d' },
            '提交整改详情': { title: '已完成', color: '#52c41a' },
        }

        return (
            <div className='SecurityOperationLog'>
                <Timeline
                    items={(() => {
                        const data = List.map(item => {
                            return ({
                                color: statusMapping[item.fullName]?.color,
                                children: (
                                    <div className='TimelineData'>
                                        <div>操作步骤 : {item.fullName}</div>
                                        <div>流程步骤 : {item.tableName}</div>
                                        <div>操作人员 : {item.userName}</div>
                                        <div>操作时间 : {item.createTime}</div>
                                        <div>联系方式 : {item.userPhone}</div>
                                        {item.reviewStatus && <div>审核状态 : {item.reviewStatus}</div>}
                                        {item.reviewTime && <div>审核时间 : {item.reviewTime}</div>}
                                        {item.reviewRemark && <div>审核说明 : {item.reviewRemark}</div>}
                                    </div>
                                )
                            })
                        })
                        return data
                    })()}
                />
            </div>
        )
    }

    if (type === 'WeChatBind') {
        return (
            <div>
                <img src={imageUrl + 'WeChatImage.jpg'} alt="" />
            </div>
        )
    }

    if (type === 'WeeklyReport') {
        const { uuid, status, friday } = row.row.data
        const [STATUS, setSTATUS] = useState(false)
        const FORMEVENT = useEventEmitter()
        FORMEVENT.useSubscription(val => {
            const { type, data } = val
            if (type === 'onDetection') {
                if (status === 0 && !STATUS) {
                    send({ method: 'post', url: 'weeklyReport', params: { uuid, OperationDate: dayjs(friday).format('YYYY-MM-DD') } }).then(res => {
                        setSTATUS(true)
                        DateEvent.emit({ type: 'onRefresh' })
                    })
                }
            }
        })

        const formItem = [
            {
                span: 24,
                formType: 'UPLOAD',
                name: 'pageSize',
                label: '周报附件',
                rules: true,
                fileType: ['img', 'mp4', 'txt'],
                fileSize: 1,
                max: 10,
                fileData: { AnnexUuid: uuid }
            },
        ]

        return (
            <div className='WeeklyReport'>
                <FormTempMapping formItem={formItem} FORMEVENT={FORMEVENT} NotSubmit detection />
            </div>
        )
    }
    if (type === 'SeeWeeklyReport') {
        const { uuid } = row.row.data
        const [AnnexList, setAnnexList] = useState([])
        useMount(() => {
            send({ method: 'get', url: 'attachments/GetAttachmentDetail', params: { AnnexUuid: uuid } }).then(res => {
                setAnnexList(res.data.list)
            })
        })
        return (
            <div className='SeeWeeklyReport'>
                {AnnexList.map(({ uuid, fileUrl, originalName }) => {
                    const type = getFileTypeFromUrl(fileUrl)
                    if (type === 'image') {
                        return (
                            <div key={uuid}>
                                <Image width={'100%'} height={'100%'} src={fileUrl} />
                            </div>
                        )
                    }
                    if (type === 'video') {
                        return (
                            <div key={uuid}>
                                <VideoTempA02 url={fileUrl} />
                            </div>
                        )
                    }
                    if (type === 'edge') {
                        return (
                            <div key={uuid} className='EDGE' onClick={() => window.open(fileUrl)}>
                                {originalName || '打开文档'}
                            </div>
                        )
                    }
                })}
            </div>
        )
    }

    if (type === 'OKWeeklyReport') {

        const statusMapping = {
            1: { label: '提交于', status: 'success' },
            2: { label: '迟交于', status: 'warning' }
        }
        const { childrenSubmitted } = row.row.data
        const [Active, setActive] = useState()
        const [Data, setData] = useState()

        const onClick = (e) => {
            if (e === Active) {
                setActive()
                return false
            }
            setActive(e)
            send({ method: 'get', url: 'weeklyReport/GetWeeklyReport', params: { uuid: e } }).then(res => {
                send({ method: 'get', url: 'attachments/GetAttachmentDetail', params: { AnnexUuid: e } }).then(annex => {
                    setData({ ht: res.data.ht, user: res.data.list, annex: annex.data.list })
                })
            })
        }

        if (childrenSubmitted.length === 0) {
            return (
                <div className='WeeklyReportLoading'>
                    <Result status="404" title="暂无已提交周报信息" />
                </div>
            )
        } else {
            return (
                <div className='OKWeeklyReport'>
                    {childrenSubmitted.map(item => {
                        const { uuid, departmentName } = item
                        const status = uuid === Active
                        return (
                            <div key={uuid} >
                                <div className='List' onClick={() => onClick(uuid)}>
                                    <div className='Title'>{departmentName}</div>
                                    <CaretRightOutlined style={{ fontSize: 24, transform: `rotate(${status ? '90' : '0'}deg)` }} />
                                </div>
                                {status &&
                                    <div className="Details">
                                        {(() => {
                                            if (!Data) {
                                                return (
                                                    <div className='DetailsLoading'>
                                                        <Spin />
                                                    </div>
                                                )
                                            } else {
                                                const BadgeStatus = statusMapping[Data.ht.status].status
                                                const BadgeText = `${statusMapping[Data.ht.status].label} : ${Data.ht.createTime}`
                                                return (
                                                    <div className='DetailsData'>
                                                        <Badge status={BadgeStatus} text={BadgeText} />
                                                        <div className='Label'>汇报给 : </div>
                                                        <div className='List'>
                                                            {Data.user.map(item =>
                                                                <Tag color={item.isRead === 0 ? 'default' : 'success'} key={item.uuid}>{item.fullName}</Tag>
                                                            )}
                                                        </div>
                                                        <div className='Label'>周报信息 : </div>
                                                        <div className='Annex'>
                                                            {Data.annex.map(item => {
                                                                const { uuid, fileUrl, originalName } = item
                                                                const type = getFileTypeFromUrl(fileUrl)
                                                                if (type === 'image') {
                                                                    return (
                                                                        <div key={uuid}>
                                                                            <Image width={'100%'} height={'100%'} src={fileUrl} />
                                                                        </div>
                                                                    )
                                                                }
                                                                if (type === 'video') {
                                                                    return (
                                                                        <div key={uuid}>
                                                                            <VideoTempA02 url={fileUrl} />
                                                                        </div>
                                                                    )
                                                                }
                                                                if (type === 'edge') {
                                                                    return (
                                                                        <div key={uuid} className='EDGE' onClick={() => window.open(fileUrl)}>
                                                                            {originalName || '打开文档'}
                                                                        </div>
                                                                    )
                                                                }
                                                            })}
                                                        </div>
                                                    </div>
                                                )
                                            }
                                        })()}
                                    </div>
                                }
                            </div>
                        )
                    })}
                </div>
            )
        }
    }

    if (type === 'NOTWeeklyReport') {
        const { childrenUnSubmitted } = row.row.data
        if (childrenUnSubmitted.length === 0) {
            return (
                <div className='WeeklyReportLoading'>
                    <Result status="404" title="暂无未提交周报信息" />
                </div>
            )
        } else {
            return (
                <div className='NOTWeeklyReport'>
                    {childrenUnSubmitted.map(item =>
                        <div key={item.uuid}>{item.departmentName}</div>
                    )}
                </div>
            )
        }
    }

    if (type === 'BusinessCard') {
        const FORMEVENT = useEventEmitter()
        const [initData, setInitData] = useState()

        const formItem = [
            { span: 24, formType: 'HIDDEN', name: 'uuid', label: 'uuid', rules: true },
            { span: 24, formType: 'UPLOAD', name: 'faceAttachment', label: '头像', rules: true, fileType: ['img'] },
            { span: 24, formType: 'UPLOAD', name: 'wechatAttachment', label: '微信', rules: true, fileType: ['img'] },
            { span: 24, formType: 'INPUT', name: 'tableName', label: '姓名', rules: true },
            { span: 24, formType: 'INPUT', name: 'position', label: '部门', rules: true },
            { span: 24, formType: 'INPUT', name: 'jobTitle', label: '职务', rules: true },
            { span: 24, formType: 'INPUT', name: 'phone', label: '联系电话', rules: true },
            { span: 24, formType: 'INPUT', name: 'email', label: '电子邮箱', rules: true },
        ]

        FORMEVENT.useSubscription(val => {
            if (val.type === 'onFormBack') {
                const { uuid } = val.data
                send({ method: uuid ? 'put' : 'post', url: 'personBusinesss', params: { ...val.data, businessPersonUuid: row.row.data.uuid } }).then(res => {
                    notification.success({ message: `${uuid ? '修改' : '添加'}成功`, description: '已更新个人名片!' })
                    Off()
                })
            }
        })

        useMount(() => {
            send({ method: 'get', url: 'personBusinesss', params: { BusinessPersonUuid: row.row.data.uuid } }).then(res => {
                const [user] = res.data.list
                setInitData(user || {})
            })
        })

        return (
            <div className='BusinessCard'>
                {initData && <FormTempMapping formItem={formItem} FORMEVENT={FORMEVENT} Initial={initData} />}
            </div>
        )
    }

    if (type === 'ViewRisks') {
        const { contractAttachment, contractTemplateAttachment, reviewStatusContent } = row.row.data
        return (
            <div className='ViewRisks'>
                <div className='left'>
                    <div className='Title'>合同信息</div>
                    <embed className='File' src={contractAttachment[0].url} />
                    {contractTemplateAttachment && <div className='Title'>模板信息</div>}
                    {contractTemplateAttachment && <embed className='File' src={contractTemplateAttachment[0].url} />}
                </div>
                <div className='right'>
                    <div className='TitleA'>· 智能解析</div>
                    <div className='TitleB'>分析结果</div>
                    <div className='content'>
                        <ScrollView
                            height='100%'
                            width='100%'
                            direction="vertical"
                            showScrollbar='onHover'
                            bounceEnabled={false}
                            elementAttr={{ class: 'style' }}
                            scrollByContent={true}
                            scrollByThumb={true}
                        >
                            <div>
                                <ReactMarkdown remarkPlugins={[[remarkGfm, { singleTilde: true }]]}  >
                                    {reviewStatusContent}
                                </ReactMarkdown>
                            </div>
                        </ScrollView>
                    </div>
                    <img src={CommonUrl + '/AIRobot.png'} alt="" />
                </div>
            </div>
        )
    }

    return (
        <div>CommonModel页面 未找到组件 - {type}</div>
    )

}

export default CommonModel;